﻿/*
 *  Download.cs - The abstract base class for classes that want to provide 
 *  download functionality.
 *
 *  Copyright (C) 2008 Dreamlusion <dreamlusion@gmail.com>
 *
 *      This program is free software; you can redistribute it and/or
 *      modify it under the terms of the GNU General Public License version
 *      2 as published by the Free Software Foundation.
 *
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Net;

namespace phpMyAdminToolkit.Common.Net
{
	/// <summary>
	/// 
	/// </summary>
	/// <remarks>
	/// http://community.bartdesmet.net/blogs/bart/archive/2006/11/25/PowerShell-_2D00_-How-to-download-a-file_3F00_.aspx
	/// </remarks>
	public abstract class Download
	{
		public event ProgressChangedEventHandler ProgressChanged;
		public virtual void OnProgressChanged(ProgressChangedEventArgs e)
		{
			BackgroundWorker worker = Worker;
			if (worker != null)
				worker.ReportProgress(e.ProgressPercentage, e.UserState);

			if (ProgressChanged != null)
				ProgressChanged(this, e);
		}

		public HttpWebRequest Request { get; set; }
		public Uri SourceUri { get; set; }

		public BackgroundWorker Worker { get; set; }
		public DoWorkEventArgs WorkEventArgs { get; set; }
	}
}
